import $axios, { Result } from '@/plugins/axios'
import { AxiosResponse } from 'axios'
import { PageParam } from '@/type'

/**
 * 分页查询区领导
 * @param param 分页查询参数
 */
export async function getDistrictLeaderByPage(
  param: PageParam,
): Promise<AxiosResponse<Result>> {
  return await $axios.post(
    '/supervision-api/districtLeader/getDistrictLeaderByPage',
    param,
  )
}

/**
 * 获得全部区领导
 */
export async function getDistrictLeaderSelect(): Promise<
  AxiosResponse<Result>
> {
  return await $axios.get(
    '/supervision-api/districtLeader/getDistrictLeaderSelect',
  )
}

/**
 * 删除区领导
 * @param ids id逗号分隔的字符串
 */
export async function deleteDistrictLeader(
  ids: string,
): Promise<AxiosResponse<Result>> {
  return await $axios.delete(
    `/supervision-api/districtLeader/deleteDistrictLeader/${ids}`,
  )
}

/**
 * 新增/修改区领导
 */
export async function addOrUpdateDistrictLeader(data: {
  id: number
  leaderType: string
  userId: number
}): Promise<AxiosResponse<Result>> {
  return await $axios.post(
    `/supervision-api/districtLeader/addOrUpdateDistrictLeader`,
    data,
  )
}
